#pragma once
#include "HashTable.h"


using namespace OPEN_HASH;

namespace ztx
{
	template<class K, class Hash = OPEN_HASH::_Hash<K>>
	class unordered_set
	{		
	private:
		struct SetOfValue
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};

		HashTable<K, K, SetOfValue, Hash> _ht;

	public:
		typedef typename HashTable<K, K, SetOfValue, Hash>::iterator iterator;

		pair<iterator, bool >  insert(const K& key)
		{
			return _ht.Insert(key);
		}

		iterator begin()
		{
			return _ht.begin();
		}

		iterator end()
		{
			return _ht.end();
		}
	};


	void test_ordered_set()
	{
		unordered_set<string> us;

		us.insert("a");
		us.insert("b");
		us.insert("aa");
		us.insert("bb");
		us.insert("c");
		us.insert("d");
		us.insert("das");

		unordered_set<string>::iterator it = us.begin();
		while (it!=us.end())
		{
			cout << *it << endl;
			++it;
		}
		cout << endl;


	}

}